home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
c01oop.zip
/
CPPWKBK
/
CPPV4-3.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-25
|
1KB
|
67 lines
#define HEADER "C++ Problem 4.3 by Rick Conn using Borland C++"
#include <stdio.h>
#include <time.h>
class time_stamp {
time_t stamp;
public:
time_stamp();
void showtime(void);
};
time_stamp::time_stamp() {
time (&stamp);
}
void time_stamp::showtime(void) {
printf("Time Stamp: %s", ctime (&stamp));
}
class message : private time_stamp {
char *msg;
public:
message (char *);
void print(void);
};
message::message (char *m) {
msg = m;
}
void message::print(void) {
printf("Message \"%s\" ", msg);
showtime();
}
class message2 : public time_stamp {
char *msg;
public:
message2 (char *);
void print(void);
};
message2::message2 (char *m) {
msg = m;
}
void message2::print(void) {
printf("Message2 \"%s\" ", msg);
showtime();
}
void main(void)
{
printf("%s\n", HEADER);
message m1("This is a test");
message2 m2("Another test");
// All member functions of message
m1.print();
// All member functions of message2
m2.print();
m2.showtime();
}